package com.example.demo.service.serviceImp;

import com.example.demo.entity.Company;
import com.example.demo.mapper.CompanyMapper;
import com.example.demo.service.CompanyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CompanyServiceImp implements CompanyService {

    @Autowired
    private CompanyMapper companyMapper;

    @Override
    public int addCompany(Company company) {
        return companyMapper.insert(company);
    }

    @Override
    public int deleteCompanyById(String id) {
        return companyMapper.deleteById(id);
    }

    @Override
    public int updateCompany(Company company) {
        return companyMapper.updateById(company);
    }

    @Override
    public List<Company> selectAll(int page, int limit, Company example) {
        int begin = limit * (page-1);
        List<Company> result = companyMapper.selectAll(begin,limit,example);
        return result;
    }

    @Override
    public int selectCounts() {
        return companyMapper.selectCount(null);
    }
}
